package com.jishuo.nontax.view.controller;

import com.jishuo.base.bean.BaseResult;
import com.jishuo.base.bean.vo.UserVO;
import com.jishuo.nontax.bean.vo.ChargeBillVO;
import com.jishuo.nontax.bfc.service.BaseDataService;
import com.jishuo.nontax.bfc.service.ChargeBillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * 缴款书
 */
@Slf4j
@Controller
@RequestMapping(value = "/view/chargebill", name = "缴款书")
public class ChargeBillViewController {
    @Resource
    private ChargeBillService chargeBillService;
    @Resource
    private BaseDataService baseDataService;

    // 页面文件位置
    private String prefix = "view/";

    @RequestMapping(value = {"chargebillview"}, name = "缴款书首页")
    public String electronindex() {
        return prefix + "chargebillview";
    }

    @RequestMapping(value = {"chargebillhandview"}, name = "缴款书首页")
    public String chargebillhandview() {
        return prefix + "chargebillhandview";
    }

    @ResponseBody
    @RequestMapping(value = "queryChargeBillData", name = "缴款书查询")
    public BaseResult queryChargeBillData(String billnum){
        return chargeBillService.getChargeBillVO(billnum);
    }

    @ResponseBody
    @RequestMapping(value = "chargebillpay", name = "收款")
    public BaseResult chargebillpay(ChargeBillVO chargeBillVO, HttpSession session){
        UserVO user = (UserVO) session.getAttribute("login_user");
        chargeBillVO.setBankstation(user.getBankStationName());
        return chargeBillService.chargebillpay(chargeBillVO);
    }

    @ResponseBody
    @RequestMapping(value = "queryChargeBillHandData", name = "收款")
    public BaseResult queryChargeBillHandData(ChargeBillVO chargeBillVO){
        return chargeBillService.setChargeBillIsActive(chargeBillVO);
    }

    @ResponseBody
    @RequestMapping(value = "findBankXml", name = "")
    public BaseResult findBankXml(ChargeBillVO chargeBillVO){
        return baseDataService.findBank(chargeBillVO.getCantonid());
    }

    @ResponseBody
    @RequestMapping(value = "chargebillhandpayview", name = "")
    public BaseResult chargebillhandpayview(String billnum, @RequestParam Map data,HttpSession session){
        UserVO user = (UserVO) session.getAttribute("login_user");
         return chargeBillService.chargebillhandpayview(billnum,data,user);
    }
}
